﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using Website.Infrastructure;

namespace Website.Tests
{
    [TestClass]
    public class AuthorizedUserManagerTests
    {
        #region constants
        const string path = "./";
        const string filename = "AuthorizedUsers.txt";
        const string allowedUser = "someone@gmail.com";
        const string disallowedUser = "someoneelse@gmail.com";
        #endregion

        [TestMethod]
        public void IsAllowedUserTest()
        {
            string filepath = Path.Combine(path, filename);

            // Arrange
            File.WriteAllText(filepath, allowedUser);

            // Act
            var authUserManager = new AuthorizedUserManager(path);
            File.Delete(filepath);

            // Assert
            Assert.IsTrue(authUserManager.IsAllowedUser(allowedUser));
            Assert.IsFalse(authUserManager.IsAllowedUser(disallowedUser));
        }
    }
}
